N = int(input())

cnt = 0
col = [False for i in range(N+1)]
slash1 = [False for i in range(2*N+1)]
slash2 = [False for i in range(2*N+1)]

def check(x,y):
    return not col[y] and not slash1[x+y] and not slash2[x-y]

def dfs(x):
    global cnt
    if x == N+1:
        cnt += 1
        return
    for y in range(1, N +1):
        if check(x,y):
            col[y] = slash1[x+y] = slash2[x-y] = True
            dfs(x+1)
            col[y] = slash1[x+y] = slash2[x-y] = False

dfs(1)
print(cnt)